package wechat.base.snd.encoding;

import org.json.JSONObject;

public class MsgEncoding extends JsonPut {

	public void setToUsers(String[] s) {
		putObj("touser", AssembleStr(s, "|"));
	}

	public void setToParties(String[] s) {
		putObj("toparty", AssembleStr(s, "|"));
	}

	public void setToTags(String[] s) {
		putObj("totag", AssembleStr(s, "|"));
	}

	public void setMsgType(String s) {
		putObj("msgtype", s);
	}

	public void setToAgentid(String s) {
		putObj("agentid", s);
	}

	public void setSafe(String s) {
		putObj("safe", s);
	}

	public void setText(JSONObject s) {
		putObj("text", s);
	}
	public void setImage(JSONObject s) {
		putObj("image", s);
	}
	public void setNews(JSONObject s) {
		putObj("news", s);
	}
	public void setMpNews(JSONObject s) {
		putObj("mpnews", s);
	}
	private String AssembleStr(String[] s, String separator) {
		String ret = "";
		int s_len = s.length - 1;
		for (String item : s) {
			ret += item;
			if (s_len-- > 0)
				ret += separator;
		}
		return ret;
	}
}
